home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 3 / Cream of the Crop 3.iso / comm / wnos5src.zip / GLOBAL.H < prev    next >
Text File  |  1993-11-23  |  9KB  |  290 lines

  1. #ifndef _GLOBAL_H
  2. #define _GLOBAL_H
  3.  
  4. #define __CPLUSPLUS             1
  5. #define __CPLUSPLUS3    1
  6.  
  7. #undef  MDEBUG                  1
  8.  
  9. /* Global definitions used by every source file.
  10.  * Some may be compiler dependent.
  11.  */
  12.  
  13. #if     defined(__TURBOC__) || defined(__STDC__) || defined(LATTICE)
  14. #define ANSIPROTO               1
  15. #if defined (MAXPATH)
  16. #undef MAXPATH
  17. #endif
  18. #define MAXPATH 80
  19. #endif
  20.  
  21. #ifndef __ARGS
  22. #ifdef  ANSIPROTO
  23. #define __ARGS(x)               x
  24. #else
  25. #define __ARGS(x)               ()
  26. #endif
  27. #endif
  28.  
  29. #if !defined(__STDIO_H)
  30. #include <stdio.h>
  31. #endif
  32.  
  33. #if !defined(__TIME_H)
  34. #include <time.h>
  35. #endif
  36.  
  37. #if     !defined(AMIGA) && (defined(LATTICE) || defined(MAC) || defined(__TURBOC__))
  38. /* These compilers require special open modes when reading binary files.
  39.  *
  40.  * "The single most brilliant design decision in all of UNIX was the
  41.  * choice of a SINGLE character as the end-of-line indicator" -- M. O'Dell
  42.  *
  43.  * "Whoever picked the end-of-line conventions for MS-DOS and the Macintosh
  44.  * should be shot!" -- P. Karn's corollary to O'Dells' declaration
  45.  */
  46. #define READ_BINARY             "rb"
  47. #define WRITE_BINARY    "wb"
  48. #define APPEND_BINARY   "ab+"
  49. #define READ_TEXT               "rt"
  50. #define WRITE_TEXT              "wt"
  51. #define APPEND_TEXT             "at+"
  52.  
  53. #else
  54.  
  55. #define READ_BINARY             "r"
  56. #define WRITE_BINARY    "w"
  57. #define APPEND_BINARY   "a+"
  58. #define READ_TEXT               "r"
  59. #define WRITE_TEXT              "w"
  60. #define APPEND_TEXT             "a+"
  61.  
  62. #endif
  63.  
  64. /* These two lines assume that your compiler's longs are 32 bits and
  65.  * shorts are 16 bits. It is already assumed that chars are 8 bits,
  66.  * but it doesn't matter if they're signed or unsigned.
  67.  */
  68. typedef long int32;                             /* 32-bit signed integer */
  69. typedef unsigned short int16;   /* 16-bit unsigned integer */
  70. #define uchar(x) ((unsigned char)(x))
  71. #define MAXINT16 65535L                 /* Largest 16-bit integer */
  72. #define MAXINT32 4294967295L    /* Largest 32-bit integer */
  73.  
  74. /*----------------------------------------------------------------------*
  75. * The "interrupt" keyword is non-standard, so make it configurable      *
  76. * The 'near' keyword is customary to those strange Intel machines       *
  77. *-----------------------------------------------------------------------*/
  78. #if defined(__TURBOC__)
  79. #  define INTERRUPT       void interrupt
  80. #  if defined __CPLUSPLUS3
  81. #     define NEAR near /*_fastcall*/
  82. #     define FASTCALL /*_fastcall*/
  83. #  else
  84. #     define NEAR near
  85. #     define FASTCALL
  86. #  endif
  87. #else
  88. #  define INTERRUPT       void
  89. #  define NEAR
  90. #  define FASTCALL
  91. #endif
  92.  
  93. /* Note that these definitions are on by default if none of the Turbo-C style
  94.  * memory model definitions are on; this avoids having to change them when
  95.  * porting to 68K environments.
  96.  */
  97. #if     !defined(__TINY__) && !defined(__SMALL__) && !defined(__MEDIUM__)
  98. #define LARGEDATA       1
  99. #endif
  100.  
  101. #if     !defined(__TINY__) && !defined(__SMALL__) && !defined(__COMPACT__)
  102. #define LARGECODE       1
  103. #endif
  104.  
  105. /* Since not all compilers support structure assignment, the ASSIGN()
  106.  * macro is used. This controls how it's actually implemented.
  107.  */
  108. #ifdef  NOSTRUCTASSIGN  /* Version for old compilers that don't support it */
  109. #define ASSIGN(a,b)     memcpy((char *)&(a),(char *)&(b),sizeof(b));
  110. #else                   /* Version for compilers that do */
  111. #define ASSIGN(a,b)     ((a) = (b))
  112. #endif
  113.  
  114. /* Define null object pointer in case stdio.h isn't included */
  115. #ifndef NULL
  116. /* General purpose NULL pointer */
  117. #define NULL (void *)0
  118. #endif
  119. #define NULLCHAR (char *)0      /* Null character pointer */
  120. #define NULLCHARP (char **)0    /* Null character pointer pointer */
  121. #define NULLINT (int *)0        /* Null integer pointer */
  122. #define NULLFP   (int (*)())0   /* Null pointer to function returning int */
  123. #define NULLVFP  (void (*)())0  /* Null pointer to function returning void */
  124. #define NULLVIFP (INTERRUPT (*)())0
  125. #define NULLFILE (FILE *)0      /* Null file pointer */
  126.  
  127. /* standard boolean constants */
  128. #define FALSE 0
  129. #define TRUE 1
  130. #define NO 0
  131. #define YES 1
  132.  
  133. /* string equality shorthand */
  134. #define STREQ(x,y) (strcmp(x,y) == 0)
  135.  
  136. /* Extract a short from a long */
  137. #define hiword(x)       ((int16)((x) >> 16))
  138. #define loword(x)       ((int16)(x))
  139.  
  140. /* Extract a byte from a short */
  141. #define hibyte(x)       ((unsigned char)((x) >> 8))
  142. #define lobyte(x)       ((unsigned char)(x))
  143.  
  144. /* Extract nibbles from a byte */
  145. #define hinibble(x)     (((x) >> 4) & 0xf)
  146. #define lonibble(x)     ((x) & 0xf)
  147.  
  148. /* Various low-level and miscellaneous functions */
  149. int dirps __ARGS((void));
  150. int getopt __ARGS((int argc,char *argv[],char *opts));
  151. int htoi __ARGS((char *));
  152. long htol __ARGS((char *));
  153. char *inbuf __ARGS((int16 port,char *buf,int16 cnt));
  154. int istate __ARGS((void));
  155. void log __ARGS((int s,int16 protocol,char *fmt, ...));
  156. int log2 __ARGS((int16 x));
  157. void *ltop __ARGS((long));
  158. void *shtop __ARGS((char *));
  159. char *outbuf __ARGS((int16 port,char *buf,int16 cnt));
  160. long ptol __ARGS((void *));
  161. void restore __ARGS((int int_status));
  162. void rflush __ARGS((void));
  163. void rip __ARGS((char *));
  164. char *timestr __ARGS((int32 gmt));
  165. int tprintf __ARGS((char *fmt,...));
  166. int tputs __ARGS((char *s));
  167. int wildmat __ARGS((char *s,char *p,char **argv));
  168.  
  169. /* in misc.c */
  170. void gethelp __ARGS((int16 ipport,int s,char *topic));
  171.  
  172. #include <stdlib.h>
  173. #include <string.h>
  174.  
  175. #ifdef  AZTEC
  176. #define rewind(fp)      fseek(fp,0L,0);
  177. #endif
  178.  
  179. #if     defined(__TURBOC__)
  180. #define movblock(so,ss,do,ds,c) movedata(ss,so,ds,do,c)
  181.  
  182. #else
  183.  
  184. /* General purpose function macros already defined in turbo C */
  185. #ifndef min
  186. #define min(x,y)        ((x)<(y)?(x):(y))       /* Lesser of two args */
  187. #endif
  188. #ifndef max
  189. #define max(x,y)        ((x)>(y)?(x):(y))       /* Greater of two args */
  190. #endif
  191.  
  192. #define MK_FP(seg,ofs)  ((void far *) \
  193.             (((unsigned long)(seg) << 16) | (unsigned)(ofs)))
  194.  
  195. #endif  /* __TURBOC __ */
  196.  
  197. /* Externals used by getopt */
  198. extern int optind;
  199. extern char *optarg;
  200.  
  201. /* check availalbe memory */
  202. extern int availmem __ARGS((void));
  203.  
  204. /* System clock - count of ticks since startup */
  205. extern int32 Clock;
  206. extern int32 currtime;
  207. extern int32 Memthresh;
  208.  
  209. #define SECONDS     (1L)
  210. #define MINUTES     (60L * SECONDS)
  211. #define HOURS       (60L * MINUTES)
  212. #define DAYS        (24L * HOURS)
  213.  
  214. extern struct timer Statustimer;
  215.  
  216. extern char uploadstatus;
  217. extern unsigned char Nrows, Ncols;
  218.  
  219. /* Various useful standard error messages */
  220. extern char Hostname[];
  221. extern char Badhost[];
  222. extern char Notval[];
  223. extern char Version[];
  224. extern char Badif[];
  225. extern char Badasy[];
  226. extern char Badax[];
  227. extern char Nosocket[];
  228. extern char Nosess[];
  229. extern char Noipaddr[];
  230. extern char Invcall[];
  231.  
  232. /* Your system's end-of-line convention */
  233. extern char Eol[];
  234.  
  235. #ifdef __CPLUSPLUS
  236. extern struct ax25_cb;
  237. extern struct dirsort;
  238. extern struct iface;
  239. extern struct ip;
  240. extern struct mbx;
  241. extern struct mbuf;
  242. extern struct nr4cb;
  243. extern struct session;
  244. extern struct slip;
  245.  
  246. #  ifndef MDEBUG
  247.       void *mxalloc(unsigned nb);
  248.       void *mxallocw(unsigned nb);
  249.       void *cxalloc(unsigned nelem,unsigned size);
  250.       void *cxallocw(unsigned nelem,unsigned size);
  251.       void xfree(void *adr);
  252.       char *strxdup(const char *s);
  253. #else
  254.       void *mxalloc(char *file,unsigned line,unsigned nb);
  255.       void *mxallocw(char *file,unsigned line,unsigned nb);
  256.       void *cxalloc(char *file,unsigned line,unsigned nelem,unsigned size);
  257.       void *cxallocw(char *file,unsigned line,unsigned nelem,unsigned size);
  258.       void xfree(char *file,unsigned line,void *adr);
  259.       char *strxdup(char *file,unsigned line,const char *s);
  260. #     ifndef __ALLOC_C
  261. #        define mxalloc(nb) mxalloc(__FILE__,__LINE__,nb)
  262. #        define mxallocw(nb) mxallocw(__FILE__,__LINE__,nb)
  263. #        define cxalloc(elem,nb) cxalloc(__FILE__,__LINE__,elem,nb)
  264. #        define cxallocw(elem,nb) cxallocw(__FILE__,__LINE__,elem,nb)
  265. #        define xfree(blk) xfree(__FILE__,__LINE__,blk)
  266. #        define strxdup(s) strxdup(__FILE__,__LINE__,s)
  267. #     endif __ALLOC_C
  268. #   endif
  269.  
  270. #endif __CPLUSPLUS
  271.  
  272. /* General structure for remote servers */
  273. struct Server {
  274.     struct Server *next;
  275.     char *name;
  276.     int32 address;
  277.     int busy;
  278.     int16 protocol;
  279.     char *arg1;
  280.     char *arg2;
  281.     char *arg3;
  282.     char *arg4;
  283. } ;
  284. #define NULLSERVER (struct Server *)0
  285.  
  286. extern struct Server *Server;
  287.  
  288. #endif  /* _GLOBAL_H */
  289.  
  290.